<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>山羊の前端小窝</title>
    <style>
        * {
            box-sizing: border-box;
            padding: 0;
            margin: 0;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background: url(./bg.jpg) no-repeat center center fixed;
            background-size: cover;
        }

        #nav {
            position: relative;
            border: none;
            border-radius: 10em;
            display: flex;
            list-style: none;
            background: #f5f5f5;
            box-shadow: 20px 40px 40px #00000033;
            padding: 10px;
        }

        #nav li a {
            position: relative;
            padding: 15px 50px;
            font: 500 24px '优设标题黑';
            border: none;
            outline: none;
            color: rgb(70, 100, 180);
            display: inline-block;
            text-decoration: none;
            z-index: 3;
        }

        .slide1,
        .slide2 {
            position: absolute;
            display: inline-block;
            height: 60px;
            border-radius: 10em;
            transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1.05);
        }

        .slide1 {
            background-color: rgb(170, 190, 255);
            z-index: 2;
        }

        .slide2 {
            opacity: 0;
            background-color: rgba(170, 190, 255, .5);
            z-index: 1;
            box-shadow: 0 0 20px #ffffffaa inset;
        }

        .squeeze {
            transform: scale(0.9);
        }
    </style>
</head>

<body>
    <ul id="nav">
        <li class="slide1"></li>
        <li class="slide2"></li>
        <li><a href="#">Alpha</a></li>
        <li><a href="#">Beta</a></li>
        <li><a href="#">Gamma</a></li>
        <li><a href="#">Delta</a></li>
        <li><a href="#">Epsilon</a></li>
    </ul>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
    $("#nav a").on("click", function () {
        var position = $(this).parent().position();
        var width = $(this).parent().width();
        $("#nav .slide1").css({ opacity: 1, left: +position.left, width: width });
    });
    $("#nav a").on("mouseover", function () {
        var position = $(this).parent().position();
        var width = $(this).parent().width();
        $("#nav .slide2").css({ opacity: 1, left: +position.left, width: width }).addClass("squeeze");
    });
    $("#nav a").on("mouseout", function () {
        $("#nav .slide2").css({ opacity: 0 }).removeClass("squeeze");
    });
    var currentWidth = $("#nav li:nth-of-type(3) a").parent("li").width();
    var current = $("li:nth-of-type(3) a").position();
    $("#nav .slide1").css({ left: +current.left, width: currentWidth });
</script>

</html>